package math;

import java.util.ArrayList;

import math.common.MathCommon;


public class KurtosisBasedMethod {
	public Double estimate(ArrayList<Double> V, ArrayList<Double> U) {
		//ksi - Normal distribution (kurtosis = 3)
		
		Double b11 = new LeastSquareMethod().estimate(V, U);
		Double b12 = new WLeastSquareMethod().estimate(V, U);
		
		//Cov(U,V) estimation and MU^4 estimation 
		Double sumUV = 0.0;
		
		int n = U.size();
		for (int i=0; i<n; i++) {
			sumUV += U.get(i)*V.get(i);
			
		}
		Double covUV = sumUV/(n-1);
		
		Double mU4 = MathCommon.get4Moment(U);
//		Double mU4 = 12.75;
		return (b11*(b11*b12*mU4 - 3*covUV*covUV))/(b11*b11*mU4 - 3*covUV*covUV);
			
	}
}
